/**
 * [3] 无重复字符的最长子串
 *
 * @format
 * @lc app=leetcode.cn id=3 lang=javascript
 */

// @lc code=start
/**
 * @param {string} s
 * @return {number}
 */
var lengthOfLongestSubstring = function (s) {
    let len = [0, 0]
    let dict
    for (let i = 0; i < s.length; i++) {
        dict = {}
        len[0] = 0
        let j = i
        while (!dict[s[j]] && s[j]) {
            dict[s[j]] = true
            j++
            len[0]++
        }
        len[0] > len[1] ? (len[1] = len[0]) : null
    }
    return len[1]
}
// @lc code=end
